package com.example.demo.error;

/**
 * 响应结果生成
 */

public class ResultGenerator {

    public static Result<?> genSuccessResult(){
        return new Result<>().setCode(ResultCode.SUCCESS);
    }

    public static Result<?> genSuccessResult(Object data){
        return new Result<>().setCode(ResultCode.SUCCESS).setData(data);
    }

    public static Result<?> genFailResult(String message){
        return new Result<>().setCode(ResultCode.FAIL).setMessage(message);
    }

    public static Result<?> genSpecialResult(ResultCode resultCode, String message){
        return new Result<>().setCode(resultCode).setMessage(message);
    }

    public static Result<?> genSuccessfulResult(Object data, String message){
        return new Result<>().setCode(ResultCode.SUCCESS).setData(data).setMessage(message);
    }

    public static Result<?> getErrorResult(String message){
        return new Result<>().setCode(ResultCode.ERROR).setMessage(message);
    }
}

